Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Relation<DistributionType> to Relation<ValueType> #70

Merged
merged 5 commits into from
Jun 26, 2024

Conversation

ThomasColthurst
Copy link
Collaborator

This has lots of advantages, including the fact that new Distributions no longer need to touch relation_variant.*
In general, I think it is a code smell for a class to be templated over a type that doesn't appear in its methods (ValueType appears in Relation's methods, but DistributionType doesn't .)

Plus fixed some memory leaks.

Plus added a typename_playground that makes it easier to iteratively write decltype and typename code and figure out what is going wrong.

Copy link
Collaborator

@emilyfertig emilyfertig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a nice simplification!

@@ -82,6 +75,15 @@ class Relation {
}
}

Distribution<ValueType>* make_new_distribution() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the answer is no, but is there any chance this could cause problems once DistributionVariant contains Distribution subclasses with the same ValueType?

Copy link
Collaborator Author

@ThomasColthurst ThomasColthurst Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. The only way the code here could go wrong is if relation_from_spec somehow returned the wrong type of Relation for a DistributionSpec -- for example, if it returned a Relation<bool> for a dist_spec that when passed to cluster_prior_from_spec returned a Distribution<double>.

But if that happened, lots of other things would go wrong, too.

@ThomasColthurst ThomasColthurst merged commit 9531ec7 into master Jun 26, 2024
1 of 2 checks passed
@ThomasColthurst ThomasColthurst deleted the 062524-thomaswc-refactor-variant branch June 26, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants